<?php
/**
 * @package Admin
 * @author Henrique Droog <henridroog@gmail.com>
 * @name RolesubmenuForm
 * @since 05/04/2011
 * @version 1.0
 */
class Admin_Form_RolesubmenuForm extends Zend_Form{
    public function init(){

        $id = new Zend_Form_Element_Hidden('id');

        // Add an email element
        $roles = new Admin_Model_RoleMapper();
        $combo = $roles->fetchAll();
        
        $comboRole = array();
        foreach ($combo as $c){
            $comboRole[$c->id] = $c->name;
        }

        $role = new Zend_Form_Element_Select('role');
        $role->setLabel('Role')
                ->setRequired(true)
                //->setAttrib('disable','disable')
                ->addValidator('NotEmpty')
                ->setMultiOptions($comboRole);

        // Add an email element
        $submenus = new Admin_Model_SubmenuMapper();
        $combosub = $submenus->selecionaAll();
        
        $comboSubmenu = array();
        foreach ($combosub as $c){
            $comboSubmenu[$c->id] = $c->menu."-".$c->name;
        }

        $submenu = new Zend_Form_Element_Select('submenu');
        $submenu->setLabel('Submenu')
                ->setRequired(true)
                ->addValidator('NotEmpty')
                ->setMultiOptions($comboSubmenu);

        // Add an email element
        $options = array('true'=>'Sim','false'=>'Não');
        $ativo = new Zend_Form_Element_Select('status');
        $ativo->setLabel('Ativo')
                ->setRequired(true)
                ->addValidator('NotEmpty')
                ->setMultiOptions($options);

        // Add the submit button
        $submit = new Zend_Form_Element_Submit('submit');
        $submit->setLabel('Enviar')
                ->setAttrib('ignore',true);


        $this->addElements( array($id,$role,$submenu,$ativo,$submit) );
    }
}